package com.wb.mianxiangduixiang.bms;

/**
 * @author 黄衡熙
 * @version 1.0
 * @date 2025年07月22日14:12
 */
//储蓄账户重写父类的取款方法
public class SavingAccount extends Account {
    @Override
    //储蓄账户取款
    public boolean withdrawMoney(double money) {
        double balance=super.getBalance();
        if (money <=balance) {
            balance=balance-money;
            super.setBalance(balance);
            System.out.println("恭喜您取款成功,账户余额为:"+balance);
        }else{
            System.out.println("取款失败，当前账户余额不足");
        }
        // 此处实现取款方法,储蓄账户只要考虑账户余额即可
        return false;

    }
    //储蓄账户转账
    public boolean transferMoney(double money, Account account1) {
        double balance=super.getBalance();
        if (money <=balance) {
            balance=balance-money;
            super.setBalance(balance);
            System.out.println("转账成功，账户余额为:"+balance);
            account1.setBalance(account1.getBalance()+money);
        }else{
            System.out.println("转账失败，当前账户余额不足");
        }
        return false;
    }
}